package com.example.activiti.config;

import com.example.activiti.model.ActUser;
import org.springframework.core.NamedThreadLocal;

/**
 * @author Mr.yuan
 * @version v1.0
 * @date 2019/11/12 14:36
 **/
public class UserLocal {

    private static final ThreadLocal<ActUser> THREAD_LOCAL = new NamedThreadLocal<>("activity");

    public static ActUser getUser() {
        if (null == THREAD_LOCAL.get()){
            THREAD_LOCAL.set(new ActUser());
        }
        return THREAD_LOCAL.get();
    }
    public static void setUser(ActUser user){
        THREAD_LOCAL.set(user);
    }
    public static void clean(){
        THREAD_LOCAL.remove();
    }
}
